package cn.lizemin.command.version1;


import cn.lizemin.command.version1.entity.Keyboard;
import cn.lizemin.command.version1.entity.KeyboardCommand;
import cn.lizemin.command.version1.entity.device.Bulb;
import cn.lizemin.command.version1.entity.device.Fridge;
import cn.lizemin.command.version1.entity.SwitchCommand;
import cn.lizemin.command.version1.entity.Switcher;

/**
 * @author lzm
 * @version 1.0
 * @description:
 * @date 2022/5/3 11:46
 */
public class Client{
    /**
     * 程序的入口
     */
    public static void main(String[] args) {
        /**
         * 存在的缺陷：
         *  开关和灯泡强耦合，我们希望开关还能够控制冰箱，空调
         *      还希望，灯泡也能够被电脑键盘控制
         */
//        使用构造器注入不如set方法灵活，轻量级
//        Switcher switcher = new Switcher(new Bulb());
//        switcher.buttonPush();
//        switcher.buttonPop();

        System.out.println("----------开关控制冰箱-------------");
        Switcher switcher = new Switcher();
        switcher.setCommand(new SwitchCommand(new Bulb()));
        switcher.buttonPush();
        switcher.buttonPop();

        System.out.println("----------开关控制冰箱-------------");
        switcher.setCommand(new SwitchCommand(new Fridge()));
        switcher.buttonPush();
        switcher.buttonPop();

        System.out.println("----------键盘控制灯泡-------------");
        Keyboard keyboard = new Keyboard();
        keyboard.setCommand(new KeyboardCommand(new Bulb()));
        keyboard.keyboardPush();
        keyboard.keyboardPop();


    }



}
